<template>
	<view class="sub-appeal-content">
		<view class="home-top">
			<view class="home-title">上传商品评价截图</view>
			<image src="../../../static/common/sub-back-icon.png" class="sub-back-icon" @tap="backpage"></image>
			<!-- <image src="../../../static/common/sbu-home-top-icon.png" class="sub-home-top-icon" @tap="contactKF"></image> -->
		</view>
		<view class="cintainer">
			<view class="product-name">
				<text class="text_name">商品名称:</text>
				<text class="good_name">{{productName}}</text>
			</view>
			<view class="product-name">
				<text class="text_name">礼品名称:</text>
				<text class="good_name">{{giftName}}</text>
			</view>
			<view class="img-box">
				<view class="up_text">请上传对应商品的五星好评截图</view>
				<image v-if="!loacalImg" src="../../../static/common/pick-img.png" class="pick-img" @tap="closeImgs"></image>
				<image v-else :src="loacalImg" class="hahah" mode="aspectFit" @tap="closeImgs"></image>
			</view>
			
			<view class="tips">
				<view style="margin-bottom: 15upx;">请务必确认已经收到货物，然后在卖家店铺进行五星好评并截图，再来本页面上传！</view>
				<view>实际未收到货，晒评价或上传虚假截图者，平台将严厉处罚，延长返款时间14天。情节严重者，冻结账号处理。</view>
			</view>
			<view class="submit_btn" @tap="submitForm">确认提交</view>
		</view>
		
	</view>
</template>

<script>
	export default{
		name:"appealDetail",
		data(){
			return{
				apptoken:"",
				appealId:"",
				imgs:"",
				loacalImg:"",
				productName:"",
				giftName:"",
				customertaskId:"",
				src:""
				
			}
		},
		onLoad(optinos) {
			this.apptoken = uni.getStorageSync("apptoken");
			this.productName = optinos.productName;
			this.giftName = optinos.giftName;
			this.customertaskId = optinos.customertaskId;
		},
		methods:{
			submitForm(){
				const _this = this;
				
				if(!this.imgs){
					this.$CommonJS.showToast("请先上传五星好评截图");
					return;
				}else{
					uni.request({
							url:this.$API.URL + this.$API.task_op,
							data:{
								apptoken:this.apptoken,
								img10:this.imgs,
								customertaskId:this.customertaskId
							},
							method:"POST",
							header:{
								'content-type':'application/x-www-form-urlencoded'
							},
							success(resp) {
								console.log(resp)
								if(resp.data.success){
									
									uni.showToast({
										title:"上传成功",
										icon:"success"
									})
									_this.loacalImg = "";
									var pages = getCurrentPages(); //当前页面栈  
									if (pages.length > 1) {  
									    var beforePage = pages[pages.length - 2]; //获取上一个页面实例对象  
									    beforePage.$vm.goOrder(2,3); //触发父页面中的方法change()  
									 }  
									_this.$CommonJS.navigateBack();
								}else{
									uni.showToast({
										title:resp.data.msg,
										icon:"none"
									})
								}
							}
					})
				}
				
			},
			closeImgs(){
				const _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function (res) {
							console.log(JSON.stringify(res.tempFilePaths));
							_this.loacalImg = res.tempFilePaths[0];
							//#ifdef APP-PLUS
								//_this.urlTobase64(res.tempFilePaths[0]);
								_this.$CommonJS.appReadFileToBase64(res.tempFilePaths[0]).then((img)=>{
									console.log(img)
									_this.imgs = img;
								})	
							//#endif
					}
				})
			},
			getImg(img){
				return	this.$CommonJS.getBaseImgUrl(img);
			},
			
			backpage(){
				this.$CommonJS.navigateBack();
			},
		}
	}
</script>

<style scoped>
	@import url("sub-evaluateDetail.css");
</style>
